From: Florian Müllner Date: Thu, 23 Feb 2017 21:54:32 +0000 (+0100) Subject: dateMenu: Use AppSettingsMonitor for world clocks X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~1013^2^2~511 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=0353ebde5dd8ae408cc246330db793664e8029ba;p=gnome-shell.git dateMenu: Use AppSettingsMonitor for world clocks When gnome-clocks is installed, there is currently a race between the GSettings schema being added to the database and the world clocks session trying to use it. The prize if we win that race is an abort in GIO, so use the newly added AppSettingsMonitor skip the race altogether. https://bugzilla.gnome.org/show_bug.cgi?id=766410 --- diff --git a/js/ui/dateMenu.js b/js/ui/dateMenu.js index 36c795046..eab55b4c7 100644 --- a/js/ui/dateMenu.js +++ b/js/ui/dateMenu.js @@ -87,9 +87,7 @@ const WorldClocksSection = new Lang.Class({ _init: function() { this._clock = new GnomeDesktop.WallClock(); - this._settings = null; this._clockNotifyId = 0; - this._changedId = 0; this._locations = []; @@ -98,8 +96,7 @@ const WorldClocksSection = new Lang.Class({ can_focus: true }); this.actor.connect('clicked', Lang.bind(this, function() { - let app = this._getClockApp(); - app.activate(); + this._clockAppMon.activateApp(); Main.overview.hide(); Main.panel.closeCalendar(); @@ -112,40 +109,25 @@ const WorldClocksSection = new Lang.Class({ this.actor.child = this._grid; - Shell.AppSystem.get_default().connect('installed-changed', - Lang.bind(this, this._sync)); + this._clockAppMon = new Util.AppSettingsMonitor('org.gnome.clocks.desktop', + 'org.gnome.clocks'); + this._clockAppMon.connect('available-changed', + Lang.bind(this, this._sync)); + this._clockAppMon.watchSetting('world-clocks', + Lang.bind(this, this._clocksChanged)); this._sync(); }, - _getClockApp: function() { - return Shell.AppSystem.get_default().lookup_app('org.gnome.clocks.desktop'); - }, - _sync: function() { - this.actor.visible = (this._getClockApp() != null); - - if (this.actor.visible) { - if (!this._settings) { - this._settings = new Gio.Settings({ schema_id: 'org.gnome.clocks' }); - this._changedId = - this._settings.connect('changed::world-clocks', - Lang.bind(this, this._clocksChanged)); - this._clocksChanged(); - } - } else { - if (this._settings) - this._settings.disconnect(this._changedId); - this._settings = null; - this._changedId = 0; - } + this.actor.visible = this._clockAppMon.available; }, - _clocksChanged: function() { + _clocksChanged: function(settings) { this._grid.destroy_all_children(); this._locations = []; let world = GWeather.Location.get_world(); - let clocks = this._settings.get_value('world-clocks').deep_unpack(); + let clocks = settings.get_value('world-clocks').deep_unpack(); for (let i = 0; i < clocks.length; i++) { let l = world.deserialize(clocks[i].location); this._locations.push({ location: l });